﻿using DryIoc;
using Prism.DryIoc;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Regions;
using PrismChessApp.Views;
using System.Windows;

using ServiceItem;
using ServiceItem.Engine;
using Module.FreePlay;
using Module.Common.Views;
using Module.Common.Common.QiPuHelper;
using Module.FuPan;
using Module.CanJuSheJi;
using Module.CanJuPoJie;
using Module.GuPu;
using Module.NumberGame;

namespace PrismChessApp
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            var window= Container.Resolve<MainWindow>();
            window.Loaded += (sender, args) =>
            {
                var manager = Container.Resolve<IRegionManager>();
                manager.RequestNavigate("ContentRegion", "QiPuWindow");  // 先显示一下，成为后台实例，便于记录棋谱
                manager.RequestNavigate("ContentRegion", "MessageLogView");
                manager.RequestNavigate("ContentRegion", "CanJuPoJieApp"); // 打开残局破解模块时，延迟较严重，此处处理后，延迟消失。？？？
                manager.Regions["ContentRegion"].NavigationService.Journal.Clear();
                //manager.RequestNavigate("ContentRegion", "FreePlayApp"); // 首页设置为自由对弈
                manager.RequestNavigate("ContentRegion", "NumberGameApp");
            };
            return window;
        }
        protected override void ConfigureModuleCatalog(IModuleCatalog mc)
        {
            mc.AddModule<CanJuPoJieModule>();
            mc.AddModule<FreePlayModule>();
            mc.AddModule<ServiceItemModule>();
            mc.AddModule<FuPanModule>();
            mc.AddModule<CanJuSheJiModule>();
            mc.AddModule<GuPuModule>();
            mc.AddModule<NumberGameModule>();
            base.ConfigureModuleCatalog(mc);

        }
        protected override void RegisterTypes(IContainerRegistry cr)
        {
            //cr.RegisterForNavigation<MainMenu>();  // 主菜单
            cr.RegisterForNavigation<MessageLogView>(); // 消息记录
            cr.RegisterForNavigation<UserQiPu>(); // 棋谱数据库
            cr.RegisterForNavigation<QiPuWindow>(); // 棋谱树显示窗口

            cr.Register<ChessPieces>();  // 棋子
            cr.Register<MovePoint>();  // 可移动点
            cr.Register<TreeNodeOfQiPu>(); // 着法存储结点类
            //Cr.RegisterSingleton<FullTreeOfQiPuManager>(); // 完全树的管理及显示类，棋谱的存储结构
            //Cr.RegisterSingleton<ConTractTreeOfQiPuManager>(); // 收缩树，自完全树转化而成，仅用于显示，比完全树更直观

            cr.RegisterSingleton<MovePointHelper>();   // 可移动点计算模块
            //cr.RegisterSingleton<SqliteHelper>();   // Sqlite 助手
            cr.RegisterSingleton<JiangJunHelper>(); // 将军状态计算模块
            cr.RegisterSingleton<UcciInfo>();
            
        }
    }
}
